package com.example.grpc.client.controller;


import com.example.grpc.client.service.MessageServiceClient;
import com.example.grpc.client.service.UserServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/message")
public class MessageController {
    
    @Autowired
    private MessageServiceClient messageServiceClient;
    @Autowired
    private UserServiceClient userServiceClient;
    
    @PostMapping("/send")
    public Object sendMessage(@RequestParam("content") String content,
                                       @RequestParam("sender") String sender) {
        return messageServiceClient.sendMessage(content, sender);
    }

    @GetMapping("/user/{userId}")
    public Object getUser(@PathVariable(name = "userId") Integer userId) {
        return userServiceClient.getUser(userId);
    }
}